/*===========================================================================+
 |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package xxhci.oracle.apps.XXIERP.TrainingEvoluation.webui;

import com.sun.java.util.collections.HashMap;

import java.io.Serializable;

import oracle.jbo.Row;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageDateFieldBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;


/**
 * Controller for ...
 */
public class xxierptrainingevalSearchCO extends OAControllerImpl {
    public static final String RCS_ID = "$Header$";
    public static final boolean RCS_ID_RECORDED = 
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

    /**
     * Layout and page setup logic for a region.
     * @param pageContext the current OA page context
     * @param webBean the web bean corresponding to the region
     */
    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);
        System.out.println("LoginName:" + pageContext.getUserName());
        System.out.println("RESPID:" + pageContext.getResponsibilityId());
        System.out.println("RESPNAME:" + pageContext.getResponsibilityName());
        
        OAApplicationModule am = pageContext.getApplicationModule(webBean);
        
        Serializable[] initParams = 
        { pageContext.getUserName().toString(), Date.getCurrentDate().toString() };
       // am.invokeMethod("getEmpDetails", initParams);
        OAViewObject vo = (OAViewObject)am.findViewObject("xxierptrainingevalEmpDetVO1");
        Row row[] = vo.getAllRowsInRange();
        
        if(vo.getRowCount()!=0)
        {
        Number PersonId = (Number)row[0].getAttribute("PersonId");

       // OAApplicationModule am = pageContext.getApplicationModule(webBean);
        if(pageContext.getParameter("xxierpRequestConfMesg")!=null && pageContext.getParameter("xxierpRequestConfMesg")!="")
        {
        OAException successMessage = 
                                 new OAException(pageContext.getParameter("xxierpRequestConfMesg").toString(), 
                                                 OAException.CONFIRMATION);
                             pageContext.putDialogMessage(successMessage);
        }
        
        }
        else {
        OAException successMessage = 
                                 new OAException("No Employee Details with user "+pageContext.getUserName().toString(), 
                                                 OAException.ERROR);
                             pageContext.putDialogMessage(successMessage);
        }

    }

    /**
     * Procedure to handle form submissions for form elements in
     * a region.
     * @param pageContext the current OA page context
     * @param webBean the web bean corresponding to the region
     */
    public void processFormRequest(OAPageContext pageContext, 
                                   OAWebBean webBean) {
        super.processFormRequest(pageContext, webBean);
        OAApplicationModule am = pageContext.getApplicationModule(webBean);


        String paramPersonAction = pageContext.getParameter(EVENT_PARAM);
        String strParamReqNo = pageContext.getParameter("paramReqNo");
        String strParamStatusId = "";
        String strEmpId = "";
        String strParamStatus = "";
        String strParamEmpDesg = "";
        if (pageContext.getParameter("event").equalsIgnoreCase("createEvoluation")) {

            strParamStatusId = "TE01";
            strParamStatus = "New";
        } else {
            strParamReqNo= pageContext.getParameter("paramReqNo");
            strParamStatus = pageContext.getParameter("paramStatus");
            strParamStatusId = pageContext.getParameter("paramStatusId");
            strParamEmpDesg = pageContext.getParameter("paramDesig");
        }
        // String strParamStatusId = pageContext.getParameter("paramStatusId");
        HashMap phm = new HashMap();


        phm.put("xxierpParamReqNo", strParamReqNo);
        phm.put("xxierpParamAction", paramPersonAction);
        phm.put("xxierpParamStatusId", strParamStatusId);
        phm.put("xxierpParamStatus", strParamStatus);
        phm.put("xxierpParamEmpDesg", strParamEmpDesg);
        if (pageContext.getParameter("event").equalsIgnoreCase("createEvoluation")) {

            System.out.println("TrainingEvalSearchCO: processing createEvoluation");
            pageContext.setForwardURL("OA.jsp?page=/xxhci/oracle/apps/XXIERP/TrainingEvoluation/webui/xxierptrainingevalCreatePG", 
                                      null, 
                                      OAWebBeanConstants.KEEP_MENU_CONTEXT, 
                                      null, phm, true, 
                                      OAWebBeanConstants.ADD_BREAD_CRUMB_YES, 
                                      OAWebBeanConstants.IGNORE_MESSAGES);
        }

else  if (pageContext.getParameter("event").equalsIgnoreCase("viewRequest")) {

            System.out.println("TrainingEvalSearchCO: processing viewRequest");
            pageContext.setForwardURL("OA.jsp?page=/xxhci/oracle/apps/XXIERP/TrainingEvoluation/webui/xxierptrainingevalCreatePG", 
                                      null, 
                                      OAWebBeanConstants.KEEP_MENU_CONTEXT, 
                                      null, phm, true, 
                                      OAWebBeanConstants.ADD_BREAD_CRUMB_YES, 
                                      OAWebBeanConstants.IGNORE_MESSAGES);
        }
    }

}
